/**
*baseCreature
*Ancestor of all creatures in JungleGo
*Date: Sept 2011
*/

#include <iostream>
#include "creature.hpp"
#include "consumable.hpp"
#include "brain.hpp"
#include "types.hpp"



static int gCreatureMaxHealth;

Creature::Creature() { }

Creature::~Creature() { }

bool Creature::eat(Consumable &con) {
    m_health += con.getHungerFill();
    if(m_health > gCreatureMaxHealth) {
        m_health = gCreatureMaxHealth;
    }
    return true;
}

void Creature::init(float rad, s_colour col, s_vector pos, s_vector vel) {
    setRadius(rad);
    *getColour() = col;
    getKinematic()->pos = pos;
    getKinematic()->vel = vel;
    m_brain = new Brain(1, 2, 4, 1);
}

void Creature::move() {
    getKinematic()->pos = getKinematic()->pos + getKinematic()->vel;
#ifdef DBG
    std::cout<<"Creature "<<
        getColour()->r<<" "<<
        getColour()->g<<" "<<
        getColour()->b<<" | "<<
        getRadius()<<" | "<<
        getKinematic()->pos.x<<" "<<
        getKinematic()->pos.y<<" | "<<
        getKinematic()->vel.x<<" "<<
        getKinematic()->vel.y<<"\n";
#endif
}

void Creature::paint() {
    s_colour * col = getColour();
    glPushMatrix();
    glTranslatef((float)(getKinematic()->pos.x),
                 (float)(getKinematic()->pos.y),
                 0.0f);
    glColor3f(col->r, col->g, col->b);
    drawCircle(getRadius());
    glPopMatrix();
}

void Creature::saveCreature(const char * filename) {

}

void Creature::loadCreature(const char * filename) {

}

int getCreatureMaxHealth() {
    return gCreatureMaxHealth;
}

void setCreatureMaxHealth(int newVal) {
    gCreatureMaxHealth = newVal;
}
